package com.study.d3_stringbuilder;

import java.util.StringJoiner;

public class Test2 {
    public static void main(String[] args) {
        //理解StringJoiner对完成拼接字符串好处
        int[] arr = new int[]{5,4,3,2,1};
        String s = join_arr(arr);
        System.out.println(s);
    }

    private static String join_arr(int[] arr) {
        StringJoiner sj = new StringJoiner(",","[","]");
        for (int i = 0; i < arr.length; i++) {
            sj.add(Integer.toString(arr[i]));
        }
        return sj.toString();
    }
}
